//
//  TwoToastController.m
//  OnionHome
//
//  Created by fengjie on 2019/9/18.
//  Copyright © 2019 FengJie. All rights reserved.
//

#import "TwoToastController.h"

@interface TwoToastController ()<UITableViewDelegate,UITableViewDataSource>
/**listView*/
@property (nonatomic,strong)UITableView*listView;
/**数据源*/
@property (nonatomic,strong)NSMutableArray*dataSoure;

@end

@implementation TwoToastController

- (void)viewDidLoad {
    [super viewDidLoad];
    ViewRadius(self.view, 4);
    [self createUI];
    
}
-(void)createUI{
    self.isHidenNaviBar = YES;
    self.view.backgroundColor = UIColorFromRGB(0xE9EEE7);
    
    UIView * view = [self createHeaderView];
    view.backgroundColor = KWhiteColor;
    
    [self.view addSubview:self.listView];
    [self.view addSubview:view];
    
    [view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.mas_equalTo(0);
        make.height.mas_equalTo(50);
    }];
    
    [self.listView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.bottom.right.mas_equalTo(0);
        make.top.mas_equalTo(view.mas_bottom).offset(0.5);
    }];

}
#pragma mark ---UITableViewDelegate,UITableViewDataSource
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.dataSoure.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([UITableViewCell class])];
    cell.textLabel.textColor = UIColorFromRGB(0x273323);
    cell.textLabel.font = BOLDSYSTEMFONT(14);
    cell.textLabel.text = self.dataSoure[indexPath.row];
    return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return (290 - 50)/5;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [self backBtnClicked];
}
-(UITableView*)listView{
    if(!_listView){
        _listView=[UITableView new];
        _listView.delegate =self;
        _listView.dataSource = self;
        _listView.scrollEnabled = NO;
        _listView.rowHeight = UITableViewAutomaticDimension;
        _listView.estimatedRowHeight = 44.0f;

        [_listView registerClass:[UITableViewCell class] forCellReuseIdentifier:NSStringFromClass(UITableViewCell.class)];
        _listView.separatorColor = SeparatorColor;
        _listView.separatorInset = UIEdgeInsetsMake(0, 16, 0, 16);
    }
    return _listView;
}
-(NSMutableArray *)dataSoure{
    if (!_dataSoure) {
        _dataSoure =[[NSMutableArray alloc] initWithObjects:@"低俗色情",@"标题党",@"内容不实",@"旧闻重复",@"垃圾内容", nil];
    }
    return _dataSoure;
}
-(UIView *)createHeaderView{
    UIView * view = UIView.new;
    
    UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setBackgroundImage:IMAGE_NAMED(@"back") forState:UIControlStateNormal];
    kWeakSelf(weakSelf);
    [button addActionHandler:^{
        [weakSelf.navigationController popViewControllerAnimated:YES];
    }];
    
    UILabel * label = UILabel.new;
    label.text = @"选择";
    label.textAlignment = NSTextAlignmentCenter;
    label.font = SYSTEMFONT(16);
    label.textColor = UIColorFromRGB(0x273323);
    
    [view addSubview:button];
    [view addSubview:label];
    
    [button mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.centerY.mas_equalTo(0);
    }];
    
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.mas_equalTo(0);
    }];
    
    return view;
}
@end
